package com.sanxiang.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sanxiang.common.CommonResult;
import com.sanxiang.mapper.OrderVOMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderVOMapper orderVOMapper;


    @GetMapping
    public CommonResult selectOrderList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "5") Integer pageSize) {
        return CommonResult.success(orderVOMapper.selectAllByPage(new Page<>(pageNum, pageSize)));
    }

    @GetMapping("/orderId")
    public CommonResult selectOrderByOrderId(@RequestParam Integer orderId) {
        return CommonResult.success(orderVOMapper.selectAllByOrderId(orderId));
    }
}


